<?php
namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
    	if (!IS_POST) {
        	$this->display();
        }
        if (IS_POST) {
        	$map['username'] = I('post.username');
        	$map['password'] = I('post.password','','md5');
        	$result = M('Admin')->where($map)->find();
       	 if($result){
        	$_SESSION['id'] = $result['id'];
            $_SESSION['username'] = $result['username'];
            $_SESSION['password'] = $result['password'];
            $this->success('登陆成功',U('Admin/Index/index'),1);
      	 }else{
            $this->error('登陆失败');
      	 }
         if($result['lock'] == 1){
            $this->error('账号被禁用，请联系超级管理员 :(') ;
         }
        }
    }
	//登陆注销
    public  function logout(){
        session(null);
        $this->success('欢迎再来',U('Login/index'),3);
    }
}